load("@rules_cc//cc:defs.bzl", "cc_test")

cc_test(
  name = "utility_test",
  size = "small",
  srcs = [
    "utility/logger/logger_test.cpp",
    "utility/id_test.cpp",
    "utility/timer_worker_test.cpp",
    "utility/thread_pool_test.cpp",
    "utility/string_utility_test.cpp",
    "utility/memory_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "metricsadaptor_test",
  srcs = [
    "libruntime/metrics_adaptor_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "libruntime_test",
  srcs = [
    "libruntime/invoke_adaptor_test.cpp",
    "libruntime/libruntime_manager_test.cpp",
    "libruntime/libruntime_test.cpp",
    "libruntime/fm_client_test.cpp",
    "libruntime/fs_intf_impl_test.cpp",
    "libruntime/waiting_object_manager_test.cpp",
    "libruntime/memory_store_test.cpp",
    "libruntime/kv_state_store_test.cpp",
    "libruntime/hetero_future_test.cpp",
    "libruntime/buffer_test.cpp",
    "libruntime/utils_test.cpp",
    "libruntime/certs_utils_test.cpp",
    "libruntime/security_test.cpp",
    "libruntime/instance_manager_test.cpp",
    "libruntime/invoke_spec_test.cpp",
    "libruntime/execution_manager_test.cpp",
    "libruntime/clients_manager_test.cpp",
    "libruntime/httpserver/common_server.h",
    "libruntime/httpserver/common_server.cpp",
    "libruntime/httpserver/async_http_server.h",
    "libruntime/httpserver/async_https_server.h",
    "libruntime/async_decre_ref_test.cpp",
    "libruntime/auto_init_test.cpp",
    "libruntime/fiber_test.cpp",
    "libruntime/fs_intf_manager_test.cpp",
    "libruntime/fs_intf_grpc_rw_test.cpp",
    "libruntime/connect_test.cpp",
    "libruntime/libruntime_config_test.cpp",
    "libruntime/resource_group_test.cpp",
    "libruntime/object_store_test.cpp",
    "libruntime/hetero_store_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//test/libruntime/mock:mock_datasystem",
    "//:runtime_lib",
  ],
  copts = [
          "-fno-access-control",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "group_test",
  srcs = [
    "libruntime/group_manager_test.cpp",
    "libruntime/function_group_test.cpp",
    "libruntime/range_group_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//test/libruntime/mock:mock_datasystem",
    "//:runtime_lib",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "task_submitter_test",
  srcs = [
    "libruntime/task_submitter_test.cpp",
    "libruntime/task_scheduler_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//test/libruntime/mock:mock_datasystem",
    "//:runtime_lib",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "http_client_test",
  srcs = [
    "libruntime/httpserver/common_server.h",
    "libruntime/httpserver/common_server.cpp",
    "libruntime/httpserver/async_http_server.h",
    "libruntime/httpserver/async_https_server.h",
    "libruntime/http_client_test.cpp",
  ],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  linkstatic = True,
)

cc_test(
  name = "ins_manager_test",
  size = "small",
  srcs = [
    "libruntime/normal_instance_manager_test.cpp",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//test/libruntime/mock:mock_datasystem",
    "//:runtime_lib",
  ],
  linkstatic = True,
)

cc_test(
  name = "object_id_pool_test",
  size = "small",
  srcs = [
    "libruntime/object_id_pool_test.cpp",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//test/libruntime/mock:mock_datasystem",
    "//:runtime_lib",
  ],
  linkstatic = True,
)

cc_test(
  name = "invoke_order_manager_test",
  size = "small",
  srcs = [
    "libruntime/invoke_order_manager_test.cpp",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
  ],
  linkstatic = True,
)

cc_test(
  name = "fs_client_test",
  size = "small",
  srcs = [
    "libruntime/fs_client_test.cpp",
    "libruntime/rt_direct_call_test.cpp"
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
    "//test/libruntime/mock:mock_datasystem",
  ],
  linkstatic = True,
)

cc_test(
  name = "dto_test",
  size = "small",
  srcs = [
    "dto/config_test.cpp",
    "dto/dataobject_test.cpp",
    "dto/affinity_test.cpp",
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
  ],
  linkstatic = True,
)

cc_test(
  name = "api_test",
  size = "small",
  srcs = [
    "api/function_executor_test.cpp",
    "api/api_test.cpp",
    "api/local_mode_test.cpp",
    "api/function_manager_test.cpp",
    "api/cluster_mode_runtime_test.cpp",
    "api/state_loader_test.cpp",
    "api/config_manager_test.cpp",
    "api/exception_test.cpp",
    "api/invoke_options_test.cpp",
    "api/code_manager_test.cpp",
    "common/common.h",
    "common/mock_libruntime.h",
  ],
  includes = ["."],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
    "//api/cpp:yr_api_lib",
  ],
  linkopts = ["-lstdc++fs", "-ldl"],
  linkstatic = True,
)

cc_test(
  name = "parallel_for_test",
  size = "small",
  srcs = [
    "api/parallel_for_local_test.cpp"
  ],
  dynamic_deps = ["//:grpc_dynamic"],
  deps = [
    "@gtest//:gtest_main",
    "//src/utility:yr_utils",
    "//:runtime_lib",
    "//api/cpp:yr_api_lib",
  ],
  linkopts = ["-lstdc++fs", "-ldl"],
  linkstatic = True,
)